#ifndef XGE_XUNIT_TEST_H_
#define XGE_XUNIT_TEST_H_
#include "xge_common_config.h"
#include "xallocator.h"
#include "xstring.h"
#include "xallstatic.h"

namespace xge{
  namespace xge_internal{
    class UTBase ;
    class UnitTest : public AllStatic {
    public:
      typedef void (*UnitTestFinishCallBack) ( UTBase* base );
      static bool RegisterUnitTestCase( UTBase* base ,const String& test_family , const String& test_case_name , size_t loop = 1 , UnitTestFinishCallBack call_back = NULL  );
      static bool RunFamilyTest( const String& test_family );
      static bool RunSingleTest( const String& test_family , const String& test_case_name );
      static void RunAllUnitTest();
      static bool IsRegistered(const String& test_family ,const String& test_case_name);
    };

    // A basic unit test class for deriving
    class UTBase : public Allocator {
    public:

      virtual void SetUp() = 0;
      virtual void TearDown()=0;
      virtual void UnitTest()=0;
      virtual ~UTBase () {}
    };

    // A basic unit test register class for deriving
    class UTRegisterBase : public Allocator  {
    public:
      UTRegisterBase(){}
      ~UTRegisterBase(){}
    };


    // Get the unique unit test class name
#define UNIT_TEST_NAME_(test_family,test_case_name)  test_family ## test_case_name ## _TEST
#include "xsimple_unittest_reg-inl.h"
#include "xsimple_unittest_case-inl.h"

#define UNIT_TEST(test_family,test_case_name) \
  UNIT_TEST_VERSION_1(test_family,test_case_name,xge::xge_internal::UTBase)


  }// namespace xge_internal
}//namespace xge

#endif// XGE_XUNIT_TEST_H_